package com.ecube.sql;

import com.ecube.mqtt.MqttUtils;
import com.ecube.mqtt.mysql.Query;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class zfState {

    public static void main(String[] args) throws InterruptedException {
        sendSwapStateMQTT("FAT", "999088" , "1");
        sendBatStateMQTT("FAT", "999088");
        sendRealDataMQTT("FAT", "999088");
        sendChargerStateMQTT("FAT", "999088");
        sendRealDate("FAT","999088");

    }

    public static void sendChargerStateMQTT(String env, String externalCode) {
        String pubTopic = Query.getProductCode(env, externalCode) + externalCode + "/S2M/state";
        String version = Query.getVersion(env,externalCode);
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Random random = new Random();
        // 生成一个随机数，范围在0（包含）到1000（不包含）之间
        double minimum = 6000;
        double maximum = 2000;
        double randomNumber = minimum + (double) (Math.random() * maximum);
        // 格式化为两位小数
        String chgOutputVolt = String.format("%.2f", randomNumber);
        double minimum1 = 500;
        double maximum1 = 100;
        double randomNumber1 = minimum1 + (double) (Math.random() * maximum1);
        // 格式化为两位小数
        String chgOutputCurr = String.format("%.2f", randomNumber1);

        String maxPower = "800";
        String maxPower1 = "800";

        String content = "{\n" +
                "    \"dataBody\": [\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"120026305064\",\n" +
                "            \"workMode\": 1,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 52,\n" +
                "                    \"batID\": \"120026305064\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 99,\n" +
                "                    \"currLimit\": 2,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 400,\n" +
                "                    \"dcMeterElect\": 206929.83,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"149,13\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"120026305064\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 99,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 201912.35,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"3,13\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": 99,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 1,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 1,\n" +
                "            \"acCont\": 2,\n" +
                "            \"cabinetNo\": 1,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"1,1,1,1,1,1,1,1,1,1\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000001\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"121153305096\",\n" +
                "            \"workMode\": 1,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 52,\n" +
                "                    \"batID\": \"121153305096\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 52,\n" +
                "                    \"currLimit\": 2,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 2,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 400,\n" +
                "                    \"dcMeterElect\": 195011.34,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"100,13\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"121153305096\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 52,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 2,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 185428.21,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"3,18\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": 52,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 2,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 1,\n" +
                "            \"acCont\": 2,\n" +
                "            \"cabinetNo\": 2,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"1,1,1,1,1,1,1,1,1,1\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000002\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"122392340122\",\n" +
                "            \"workMode\": 1,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 52,\n" +
                "                    \"batID\": \"122392340122\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 32,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 1,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 209435.63,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"200,12\",\n" +
                "                    \"connOutCont\": \"1,1\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"122392340122\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 31.6,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 1,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 203352.63,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"5,1\",\n" +
                "                    \"connOutCont\": \"1,1\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": 32,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 1,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 1,\n" +
                "            \"acCont\": 1,\n" +
                "            \"cabinetNo\": 3,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"2,2,2,2,2,2,2,2,2,2\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000003\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"-\",\n" +
                "            \"workMode\": 1,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 52,\n" +
                "                    \"batID\": \"-\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": -999,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 2,\n" +
                "                    \"auxPowerState\": 1,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 186014.64,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"1,1\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"-\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": -999,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 2,\n" +
                "                    \"auxPowerState\": 1,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 180513.55,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"1,1\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": -999,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 1,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 2,\n" +
                "            \"acCont\": 1,\n" +
                "            \"cabinetNo\": 4,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"2,2,2,2,2,2,2,2,2,2\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000004\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"1242543B0556\",\n" +
                "            \"workMode\": 4,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 52,\n" +
                "                    \"batID\": \"1242543B0556\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 4,\n" +
                "                    \"soc\": 77,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 2,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 906981.4,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"-\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 0,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 890090.05,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": 77.0,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 2,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 1,\n" +
                "            \"acCont\": 2,\n" +
                "            \"cabinetNo\": 5,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"2,2,2,2,2,2,2,2,2,2\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000005\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"121153305104\",\n" +
                "            \"workMode\": 4,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 52,\n" +
                "                    \"batID\": \"121153305104\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 4,\n" +
                "                    \"soc\": 45,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 2,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 888835.62,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"-\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 0,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 882633.43,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": 45,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 2,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 1,\n" +
                "            \"acCont\": 2,\n" +
                "            \"cabinetNo\": 6,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"2,2,2,2,2,2,2,2,2,2\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000006\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"122226340267\",\n" +
                "            \"workMode\": 4,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 52,\n" +
                "                    \"batID\": \"122226340267\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 4,\n" +
                "                    \"soc\": 91,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 2,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 827475.74,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"-\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 0,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 2,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 819006.08,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"2,2\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": 91,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 2,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 1,\n" +
                "            \"acCont\": 2,\n" +
                "            \"cabinetNo\": 7,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"2,2,2,2,2,2,2,2,2,2\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000007\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"door\": 1,\n" +
                "            \"plugSameBat\": 2,\n" +
                "            \"comm\": 1,\n" +
                "            \"batID\": \"121153305112\",\n" +
                "            \"workMode\": 4,\n" +
                "            \"emergStop\": 1,\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"stopReason\": 999,\n" +
                "                    \"batID\": \"121153305112\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"workMode\": 4,\n" +
                "                    \"soc\": 54,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 1,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 848288.08,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"1,1\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"stopReason\": 0,\n" +
                "                    \"batID\": \"-\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"workMode\": 1,\n" +
                "                    \"soc\": 0,\n" +
                "                    \"currLimit\": 1,\n" +
                "                    \"batFault\": \"-\",\n" +
                "                    \"chgState\": 1,\n" +
                "                    \"gunOutCont\": \"1,1\",\n" +
                "                    \"fuseAlarm\": 1,\n" +
                "                    \"batConn\": 1,\n" +
                "                    \"auxPowerState\": 1,\n" +
                "                    \"limitVal\": 0,\n" +
                "                    \"dcMeterElect\": 849271.5,\n" +
                "                    \"auxPowerVolt\": 2,\n" +
                "                    \"elecLock\": 0,\n" +
                "                    \"plugTemp\": \"0,0\",\n" +
                "                    \"connOutCont\": \"1,1\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"chgSwitch\": 0,\n" +
                "            \"soc\": 54,\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgFault\": \"-\",\n" +
                "            \"batFault\": \"-\",\n" +
                "            \"chgState\": 1,\n" +
                "            \"startType\": 1,\n" +
                "            \"chgRunMode\": 1,\n" +
                "            \"batConn\": 1,\n" +
                "            \"acCont\": 1,\n" +
                "            \"cabinetNo\": 8,\n" +
                "            \"batState\": 1,\n" +
                "            \"moduleState\": \"2,2,2,2,2,2,2,2,2,2\",\n" +
                "            \"smokeAlarm\": 1,\n" +
                "            \"chgID\": \"9990880001000008\"\n" +
                "        }\n" +
                "    ],\n" +
                "    \"header\": {\n" +
                "        \"timeStamp\": \"" + dateFormat.format(date) + "\",\n" +
                "        \"reason\": 1,\n" +
                "        \"function\": \"chargerState\",\n" +
                "        \"index\": 421881,\n" +
                "        \"version\": \"V3.0.2\"\n" +
                "    }\n" +
                "}";

        MqttUtils.sendMQTT(env, pubTopic, content);

    }
    public static void sendRealDataMQTT(String env, String externalCode) {
        String pubTopic = Query.getProductCode(env, externalCode) + externalCode + "/S2M/state";
        String version = Query.getVersion(env,externalCode);
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Random random = new Random();
        // 生成一个随机数，范围在0（包含）到1000（不包含）之间
        double minimum = 6000;
        double maximum = 2000;
        double randomNumber = minimum + (double) (Math.random() * maximum);
        // 格式化为两位小数
        String chgOutputVolt = String.format("%.2f", randomNumber);
        double minimum1 = 500;
        double maximum1 = 100;
        double randomNumber1 = minimum1 + (double) (Math.random() * maximum1);
        // 格式化为两位小数
        String chgOutputCurr = String.format("%.2f", randomNumber1);

        String maxPower = "800";
        String maxPower1 = "800";


        String content = "{\n" +
                "    \"dataBody\": [\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"moduleList\": [\n" +
                "                {\n" +
                "                    \"temp\": 22,\n" +
                "                    \"volt\": 707.2,\n" +
                "                    \"moduleNo\": 1,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 21,\n" +
                "                    \"volt\": 677.8,\n" +
                "                    \"moduleNo\": 2,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 21,\n" +
                "                    \"volt\": 678.3,\n" +
                "                    \"moduleNo\": 3,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 22,\n" +
                "                    \"volt\": 677.6,\n" +
                "                    \"moduleNo\": 4,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 22,\n" +
                "                    \"volt\": 677.4,\n" +
                "                    \"moduleNo\": 5,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 25,\n" +
                "                    \"volt\": 676.6,\n" +
                "                    \"moduleNo\": 6,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 20,\n" +
                "                    \"volt\": 678.6,\n" +
                "                    \"moduleNo\": 7,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 20,\n" +
                "                    \"volt\": 695.6,\n" +
                "                    \"moduleNo\": 8,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 21,\n" +
                "                    \"volt\": 678.1,\n" +
                "                    \"moduleNo\": 9,\n" +
                "                    \"curr\": 21.5\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 27,\n" +
                "                    \"volt\": 677.7,\n" +
                "                    \"moduleNo\": 10,\n" +
                "                    \"curr\": 21.5\n" +
                "                }\n" +
                "            ],\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"chgOutputCurr\": 215.9,\n" +
                "                    \"batID\": \"120026305064\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"soc\": 97,\n" +
                "                    \"chgQty\": 202.74,\n" +
                "                    \"voltDemand\": 700.8,\n" +
                "                    \"dcMeterElect\": 206930.73,\n" +
                "                    \"chgMode\": 2,\n" +
                "                    \"currDemand\": 215.89999999999998,\n" +
                "                    \"startTime\": \"2025-01-13 15:38:41\",\n" +
                "                    \"chgTime\": 2914,\n" +
                "                    \"chgOutputVolt\": 676.8,\n" +
                "                    \"plugTemp\": \"169,13\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"chgOutputCurr\": 0,\n" +
                "                    \"batID\": \"120026305064\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"soc\": 97.2,\n" +
                "                    \"chgQty\": 0,\n" +
                "                    \"voltDemand\": 700.8,\n" +
                "                    \"dcMeterElect\": 201913.25,\n" +
                "                    \"chgMode\": 2,\n" +
                "                    \"currDemand\": 215.89999999999998,\n" +
                "                    \"startTime\": \"2025-01-13 15:38:41\",\n" +
                "                    \"chgTime\": 2914,\n" +
                "                    \"chgOutputVolt\": 676.8,\n" +
                "                    \"plugTemp\": \"3,37\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgID\": \"9990880001000001\",\n" +
                "            \"cabinetNo\": 1\n" +
                "        },\n" +
                "        {\n" +
                "            \"gunNum\": 2,\n" +
                "            \"moduleList\": [\n" +
                "                {\n" +
                "                    \"temp\": 24,\n" +
                "                    \"volt\": 664.5,\n" +
                "                    \"moduleNo\": 1,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 29,\n" +
                "                    \"volt\": 664.1,\n" +
                "                    \"moduleNo\": 2,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 24,\n" +
                "                    \"volt\": 664.3,\n" +
                "                    \"moduleNo\": 3,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 22,\n" +
                "                    \"volt\": 665.7,\n" +
                "                    \"moduleNo\": 4,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 28,\n" +
                "                    \"volt\": 691.1,\n" +
                "                    \"moduleNo\": 5,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 23,\n" +
                "                    \"volt\": 664.4,\n" +
                "                    \"moduleNo\": 6,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 23,\n" +
                "                    \"volt\": 663.9,\n" +
                "                    \"moduleNo\": 7,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 24,\n" +
                "                    \"volt\": 664.5,\n" +
                "                    \"moduleNo\": 8,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 23,\n" +
                "                    \"volt\": 663.8,\n" +
                "                    \"moduleNo\": 9,\n" +
                "                    \"curr\": 39.7\n" +
                "                },\n" +
                "                {\n" +
                "                    \"temp\": 23,\n" +
                "                    \"volt\": 666.2,\n" +
                "                    \"moduleNo\": 10,\n" +
                "                    \"curr\": 39.7\n" +
                "                }\n" +
                "            ],\n" +
                "            \"gunList\": [\n" +
                "                {\n" +
                "                    \"chgOutputCurr\": 400.2,\n" +
                "                    \"batID\": \"121153305096\",\n" +
                "                    \"gunNo\": 1,\n" +
                "                    \"soc\": 90,\n" +
                "                    \"chgQty\": 68.73,\n" +
                "                    \"voltDemand\": 700.8,\n" +
                "                    \"dcMeterElect\": 195012.96,\n" +
                "                    \"chgMode\": 2,\n" +
                "                    \"currDemand\": 400,\n" +
                "                    \"startTime\": \"2025-01-13 16:11:21\",\n" +
                "                    \"chgTime\": 952,\n" +
                "                    \"chgOutputVolt\": 663.1,\n" +
                "                    \"plugTemp\": \"101,13\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"chgOutputCurr\": 0,\n" +
                "                    \"batID\": \"121153305096\",\n" +
                "                    \"gunNo\": 2,\n" +
                "                    \"soc\": 90,\n" +
                "                    \"chgQty\": 0,\n" +
                "                    \"voltDemand\": 700.8,\n" +
                "                    \"dcMeterElect\": 185429.9,\n" +
                "                    \"chgMode\": 2,\n" +
                "                    \"currDemand\": 400,\n" +
                "                    \"startTime\": \"2025-01-13 16:11:21\",\n" +
                "                    \"chgTime\": 952,\n" +
                "                    \"chgOutputVolt\": 663.1,\n" +
                "                    \"plugTemp\": \"3,18\"\n" +
                "                }\n" +
                "            ],\n" +
                "            \"moduleNum\": 10,\n" +
                "            \"chgID\": \"9990880001000007\",\n" +
                "            \"cabinetNo\": 7\n" +
                "        }\n" +
                "    ],\n" +
                "    \"header\": {\n" +
                "        \"timeStamp\": \"" + dateFormat.format(date) + "\",\n" +
                "        \"reason\": 2,\n" +
                "        \"function\": \"chargeState\",\n" +
                "        \"index\": 421941,\n" +
                "        \"version\": \"V3.0.2\"\n" +
                "    }\n" +
                "}";

        MqttUtils.sendMQTT(env, pubTopic, content);

    }

    public static void sendSwapStateMQTT(String env, String externalCode, String state) {
        String pubTopic = Query.getProductCode(env, externalCode) + externalCode + "/S2M/state";
        String version = Query.getVersion(env,externalCode);
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Random random = new Random();


        String content = "{\n" +
                "    \"dataBody\": {\n" +
                "        \"newCabinetNo\": -999,\n" +
                "        \"stationNo\": \"999088\",\n" +
                "        \"orderSn\": \"-\",\n" +
                "        \"seatState\": -1,\n" +
                "        \"swapType\": 2,\n" +
                "        \"oldCabinetNo\": -999,\n" +
                "        \"swapStepDesc\": \"换电：换电完成。\",\n" +
                "        \"snno\": 78426,\n" +
                "        \"swapPlace\": 99,\n" +
                "        \"movePlace\": \"1,1,1,1,1,1,1,1\",\n" +
                "        \"lockState\": -1,\n" +
                "        \"timeStamp\": \"2025-01-10 13:47:12\",\n" +
                "        \"productCode\": \"100030001\",\n" +
                "        \"swapMode\": 1,\n" +
                "        \"vin\": \"LUECBFA87RN294451\",\n" +
                "        \"swapStep\": 440,\n" +
                "        \"state\": 2,\n" +
                "        \"lane\": 1\n" +
                "    },\n" +
                "    \"header\": {\n" +
                "        \"timeStamp\": \"" + dateFormat.format(date) + "\",\n" +
                "        \"reason\": 1,\n" +
                "        \"function\": \"swapState\",\n" +
                "        \"index\": 78426,\n" +
                "        \"version\": \"V3.0.2\"\n" +
                "    }\n" +
                "}";

        MqttUtils.sendMQTT(env, pubTopic, content);

    }

    public static void sendBatStateMQTT(String env, String externalCode) {
        String pubTopic = Query.getProductCode(env, externalCode) + externalCode + "/S2M/state";
        String version = Query.getVersion(env,externalCode);
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Random random = new Random();


        String content = "{\n" +
                "    \"dataBody\": [\n" +
                "            {\n" +
                "                \"batID\": \"120026305064\",\n" +
                "                \"totalChgElect\": 18057.2,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"ratedVolt\": 618.2,\n" +
                "                \"chgSwitch\": 0,\n" +
                "                \"soc\": 97,\n" +
                "                \"ratedElect\": 281.9,\n" +
                "                \"totalGunElect\": 7352.3,\n" +
                "                \"soh\": 100,\n" +
                "                \"totalRepaymentElect\": 2038.4,\n" +
                "                \"manufacturer\": 1,\n" +
                "                \"cabinetNo\": 1,\n" +
                "                \"ratedCapacity\": 456,\n" +
                "                \"coolingType\": 3,\n" +
                "                \"totalDischgElect\": 19215,\n" +
                "                \"batType\": 3,\n" +
                "                \"totalSwapElect\": 9839.3\n" +
                "            },\n" +
                "            {\n" +
                "                \"batID\": \"121153305096\",\n" +
                "                \"totalChgElect\": 205147.7,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"ratedVolt\": 618.2,\n" +
                "                \"chgSwitch\": 0,\n" +
                "                \"soc\": 52,\n" +
                "                \"ratedElect\": 281.9,\n" +
                "                \"totalGunElect\": 17829.9,\n" +
                "                \"soh\": 92,\n" +
                "                \"totalRepaymentElect\": 20600.9,\n" +
                "                \"manufacturer\": 1,\n" +
                "                \"cabinetNo\": 2,\n" +
                "                \"ratedCapacity\": 456,\n" +
                "                \"coolingType\": 3,\n" +
                "                \"totalDischgElect\": 216335.5,\n" +
                "                \"batType\": 3,\n" +
                "                \"totalSwapElect\": 177713.6\n" +
                "            },\n" +
                "            {\n" +
                "                \"batID\": \"122392340122\",\n" +
                "                \"totalChgElect\": 0,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"ratedVolt\": 618.2,\n" +
                "                \"chgSwitch\": 0,\n" +
                "                \"soc\": 32,\n" +
                "                \"ratedElect\": 281.9,\n" +
                "                \"totalGunElect\": 0,\n" +
                "                \"soh\": 91.60000000000001,\n" +
                "                \"totalRepaymentElect\": 0,\n" +
                "                \"manufacturer\": 1,\n" +
                "                \"cabinetNo\": 3,\n" +
                "                \"ratedCapacity\": 456,\n" +
                "                \"coolingType\": 3,\n" +
                "                \"totalDischgElect\": 0,\n" +
                "                \"batType\": 3,\n" +
                "                \"totalSwapElect\": 0\n" +
                "            },\n" +
                "            {\n" +
                "                \"batID\": \"1242543B0556\",\n" +
                "                \"totalChgElect\": 21967.6,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"ratedVolt\": 618.2,\n" +
                "                \"chgSwitch\": 0,\n" +
                "                \"soc\": 77,\n" +
                "                \"ratedElect\": 6553.5,\n" +
                "                \"totalGunElect\": 8729.5,\n" +
                "                \"soh\": 94.4,\n" +
                "                \"totalRepaymentElect\": 2806.8,\n" +
                "                \"manufacturer\": -1,\n" +
                "                \"cabinetNo\": 5,\n" +
                "                \"ratedCapacity\": 456,\n" +
                "                \"coolingType\": -1,\n" +
                "                \"totalDischgElect\": 23255,\n" +
                "                \"batType\": 3,\n" +
                "                \"totalSwapElect\": 11738.8\n" +
                "            },\n" +
                "            {\n" +
                "                \"batID\": \"121153305104\",\n" +
                "                \"totalChgElect\": 216631.8,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"ratedVolt\": 618.2,\n" +
                "                \"chgSwitch\": 0,\n" +
                "                \"soc\": 45,\n" +
                "                \"ratedElect\": 6553.5,\n" +
                "                \"totalGunElect\": 19776,\n" +
                "                \"soh\": 94.4,\n" +
                "                \"totalRepaymentElect\": 21877.7,\n" +
                "                \"manufacturer\": -1,\n" +
                "                \"cabinetNo\": 6,\n" +
                "                \"ratedCapacity\": 456,\n" +
                "                \"coolingType\": -1,\n" +
                "                \"totalDischgElect\": 229177.6,\n" +
                "                \"batType\": 3,\n" +
                "                \"totalSwapElect\": 187360.4\n" +
                "            },\n" +
                "            {\n" +
                "                \"batID\": \"122226340267\",\n" +
                "                \"totalChgElect\": 161799,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"ratedVolt\": 618.2,\n" +
                "                \"chgSwitch\": 0,\n" +
                "                \"soc\": 90,\n" +
                "                \"ratedElect\": 6553.5,\n" +
                "                \"totalGunElect\": 11674.6,\n" +
                "                \"soh\": 92.4,\n" +
                "                \"totalRepaymentElect\": 17708.8,\n" +
                "                \"manufacturer\": -1,\n" +
                "                \"cabinetNo\": 7,\n" +
                "                \"ratedCapacity\": 456,\n" +
                "                \"coolingType\": -1,\n" +
                "                \"totalDischgElect\": 170914,\n" +
                "                \"batType\": 3,\n" +
                "                \"totalSwapElect\": 141258.8\n" +
                "            },\n" +
                "            {\n" +
                "                \"batID\": \"121153305112\",\n" +
                "                \"totalChgElect\": 204509.4,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"ratedVolt\": 618.2,\n" +
                "                \"chgSwitch\": 0,\n" +
                "                \"soc\": 54,\n" +
                "                \"ratedElect\": 6553.5,\n" +
                "                \"totalGunElect\": 13297.4,\n" +
                "                \"soh\": 94.80000000000001,\n" +
                "                \"totalRepaymentElect\": 20474,\n" +
                "                \"manufacturer\": -1,\n" +
                "                \"cabinetNo\": 8,\n" +
                "                \"ratedCapacity\": 456,\n" +
                "                \"coolingType\": -1,\n" +
                "                \"totalDischgElect\": 215887.6,\n" +
                "                \"batType\": 3,\n" +
                "                \"totalSwapElect\": 181954.5\n" +
                "            }\n" +
                "        ],\n" +
                "    \"header\": {\n" +
                "        \"timeStamp\": \"" + dateFormat.format(date) + "\",\n" +
                "        \"reason\": 2,\n" +
                "        \"function\": \"batState\",\n" +
                "        \"index\": 421865,\n" +
                "        \"version\": \"V3.0.2\"\n" +
                "    }\n" +
                "}\n";

        MqttUtils.sendMQTT(env, pubTopic, content);

    }

    public static void sendRealDate(String env, String externalCode){
        String pubTopic = Query.getProductCode(env, externalCode) + externalCode + "/S2M/state";
        String version = Query.getVersion(env,externalCode);
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Random random = new Random();

        //充电过程实时状态
        String content3 = "{\n" +
                "    \"dataBody\": {\n" +
                "        \n" +
                "        \"chgList\": [\n" +
                "            {\n" +
                "                \"batMaxVoltNo\": 4,\n" +
                "                \"gunNo\": 1,\n" +
                "                \"soc\": 90,\n" +
                "                \"batMinTemp\": 39,\n" +
                "                \"voltDemand\": 700.8,\n" +
                "                \"remainderChgTime\": 64,\n" +
                "                \"currDemand\": 0,\n" +
                "                \"vin\": \"-\",\n" +
                "                \"startTime\": \"2024-10-22 18:04:33\",\n" +
                "                \"chgTime\": 3081,\n" +
                "                \"chgOutputVolt\": 650.5,\n" +
                "                \"plugTemp\": \"0,0\",\n" +
                "                \"chgID\": \"9990880001000007\",\n" +
                "                \"batMaxTemp\": 49,\n" +
                "                \"batMinVoltNo\": 0,\n" +
                "                \"chgOutputCurr\": 40.9,\n" +
                "                \"batID\": \"999BBDADA007\",\n" +
                "                \"batMinVolt\": 0,\n" +
                "                \"chgQty\": 188.57,\n" +
                "                \"batMaxVolt\": 3.7,\n" +
                "                \"cabinetNo\": 7,\n" +
                "                \"dcMeterElect\": 530481.17,\n" +
                "                \"chgMode\": 2,\n" +
                "                \"batMaxTempNo\": 3,\n" +
                "                \"batMinTempNo\": 7\n" +
                "            }\n" +
                "        ],\n" +
                "        \"chgNum\": 1\n" +
                "    },\n" +
                "    \"header\": {\n" +
                "        \"timeStamp\": \"" + dateFormat.format(date) + "\",\n" +
                "        \"reason\": 2,\n" +
                "        \"function\": \"chargingData\",\n" +
                "        \"index\": 35306,\n" +
                "        \"version\": \"V3.0.7\"\n" +
                "    }\n" +
                "}";
        MqttUtils.sendMQTT(env, pubTopic, content3);
    }
}
